<?php
require('../../../../lib/base.php');
$base=new base('web');
$session=$base->library('session',array('build'=>false));
if(!$session->ISSESS()){
	$helper=$base->library('helper');
	$helper->SMessage(5,domain.'view/Login.php?back='.domain.'home/account/info.php',"no","登陆失效,5秒后转到登陆页");
}else{
	$data['menu']=$base->cache(array('tag'=>'web.header','time'=>86400));
	$data['menu']=unserialize($data['menu']);
	$data['HomeMenu']=$base->cache(array('tag'=>'web.home.menu','time'=>86400));
	$data['HomeMenu']=unserialize($data['HomeMenu']);
	$data['foot']=$base->cache(array('tag'=>'web.footer','time'=>86400));

	$mation=$base->model('information');
	if($base->post('submit',true)){
		$data['message']=array('result'=>false,'msg'=>array());
		$name=$base->post('name',true);
		$IDcard=$base->post('IDcard',true);
		$phone=$base->post('phone',true);
		$msn=$base->post('msn',true);
		$qq=$base->post('qq',true);
		$helper=$base->library('helper');
		if(empty($name)){
			$data['message']['msg'][]='姓名不可为空.';
		}else if(!$helper->CPhone($phone)){
			$data['message']['msg'][]='您输入的联系电话不是一个有效的号码.';
		}else{
			if(empty($mation)){
				$affected=$mation->IMation(array('member'=>$session->GVAR('member'),'name'=>$name,'IDcard'=>$IDcard,'phone'=>$phone,'msn'=>$msn,'qq'=>$qq));
			}else{
				$affected=$mation->UMation(array('set'=>array('name ='=>$name,'IDcard'=>$IDcard,'phone ='=>$phone,'msn ='=>$msn,'qq ='=>$qq),'where'=>array('member ='=>intval($session->GVAR('member')))));
			}
			if($affected==1){
				$data['message']['result']=true;
				$data['message']['msg'][]='个人信息修改成功.';
			}else{
				$data['message']['msg'][]='请误重复提交.';
			}
		}
	}
	$data['mation']=$mation->GMation(array('where'=>array('member ='=>$session->GVAR('member'))));
	$data['mation']=reset($data['mation']);
	$base->set($data);
	$base->view('home/account/info.php');
}
?>